VideoPlayer Class

Description

VideoPlayer是视频播放类。

EasyAR支持普通的视频、透明视频和流媒体播放。视频内容会被渲染到传入setRenderTexture的texture上。

该类只支持OpenGLES2的texture。

由于依赖于OpenGLES,本类的所有函数(包括析构函数)都必须在单个包含OpenGLES上下文的线程中调用。

当前版本要求宽高均为16的倍数。

支持的视频文件格式

Windows: Media Foundation兼容格式,安装额外的解码器可以支持更多格式,请参考 Supported Media Formats in Media Foundation ,不支持DirectShow

Mac: 不支持

Android: 系统支持的格式,请参考 Supported media formats

iOS: 系统支持的格式,当前没有有效的参考文档

Constructor

C

void easyar_VideoPlayer__ctor(easyar_VideoPlayer * * Return)

C++17

VideoPlayer()

C++03(Deprecated)

VideoPlayer()

Java

public VideoPlayer()

Kotlin

constructor()

Objective-C

+ (easyar_VideoPlayer *) create

Swift

public convenience init()

C#

public VideoPlayer()

isAvailable

检查是否可用。只在Windows、Android和iOS上返回true,Mac上不可用。

C

bool easyar_VideoPlayer_isAvailable(void)

C++17

static bool isAvailable()

C++03(Deprecated)

static bool isAvailable()

Java

public static boolean isAvailable()

Kotlin

companion object fun isAvailable(): Boolean

Objective-C

+ (bool)isAvailable

Swift

public static func isAvailable() -> Bool

C#

public static bool isAvailable()

setVideoType

设置视频类型。如果没有手动设置,将默认为普通类型。这个方法需要在open之前调用。

C

void easyar_VideoPlayer_setVideoType(easyar_VideoPlayer * This, easyar_VideoType videoType)

C++17

void setVideoType(VideoType videoType)

C++03(Deprecated)

void setVideoType(VideoType videoType)

Java

public void setVideoType(int videoType)

Kotlin

fun setVideoType(videoType: Int): Unit

Objective-C

- (void)setVideoType:(easyar_VideoType)videoType

Swift

public func setVideoType(_ videoType: VideoType) -> Void

C#

public virtual void setVideoType(VideoType videoType)

setRenderTexture

传入用来显示视频的texture到播放器。这个方法需要在open之前调用。

C

void easyar_VideoPlayer_setRenderTexture(easyar_VideoPlayer * This, easyar_TextureId * texture)

C++17

void setRenderTexture(std::shared_ptr<TextureId> texture)

C++03(Deprecated)

void setRenderTexture(TextureId * texture)

Java

public void setRenderTexture(@Nonnull TextureId texture)

Kotlin

fun setRenderTexture(texture: TextureId): Unit

Objective-C

- (void)setRenderTexture:(easyar_TextureId *)texture

Swift

public func setRenderTexture(_ texture: TextureId) -> Void

C#

public virtual void setRenderTexture(TextureId texture)

open

从 path 打开视频。

path 可以是本地视频文件(path/to/video.mp4)或url(http://www.../.../video.mp4)。storageType 表示path的类型。详细描述参见 StorageType

这个方法是异步的方法。open可能会花一些时间才能完成。如果你希望知道视频打开的结果或播放中的状态,需要处理callback数据。callback会在callbackScheduler对应的线程中被调用。你可以在回调中检查打开是否成功结束并在成功打开之后开始播放。

C

void easyar_VideoPlayer_open(easyar_VideoPlayer * This, easyar_String * path, easyar_StorageType storageType, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromVideoStatus callback)

C++17

void open(std::string path, StorageType storageType, std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(VideoStatus)>> callback)

C++03(Deprecated)

void open(String * path, StorageType storageType, CallbackScheduler * callbackScheduler, OptionalOfFunctorOfVoidFromVideoStatus callback)

Java

public void open(java.lang.@Nonnull String path, int storageType, @Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromVideoStatus callback)

Kotlin

fun open(path: String, storageType: Int, callbackScheduler: CallbackScheduler, callback: FunctorOfVoidFromVideoStatus?): Unit

Objective-C

- (void)open:(NSString *)path storageType:(easyar_StorageType)storageType callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_VideoStatus status))callback

Swift

public func `open`(_ path: String, _ storageType: StorageType, _ callbackScheduler: CallbackScheduler, _ callback: ((VideoStatus) -> Void)?) -> Void

C#

public virtual void open(string path, StorageType storageType, CallbackScheduler callbackScheduler, Optional<Action<VideoStatus>> callback)

close

关闭视频。

C

void easyar_VideoPlayer_close(easyar_VideoPlayer * This)

C++17

void close()

C++03(Deprecated)

void close()

Java

public void close()

Kotlin

fun close(): Unit

Objective-C

- (void)close

Swift

public func close() -> Void

C#

public virtual void close()

play

开始或继续播放视频。

C

bool easyar_VideoPlayer_play(easyar_VideoPlayer * This)

C++17

bool play()

C++03(Deprecated)

bool play()

Java

public boolean play()

Kotlin

fun play(): Boolean

Objective-C

- (bool)play

Swift

public func play() -> Bool

C#

public virtual bool play()

stop

停止视频播放。

C

void easyar_VideoPlayer_stop(easyar_VideoPlayer * This)

C++17

void stop()

C++03(Deprecated)

void stop()

Java

public void stop()

Kotlin

fun stop(): Unit

Objective-C

- (void)stop

Swift

public func stop() -> Void

C#

public virtual void stop()

pause

暂停视频播放。

C

void easyar_VideoPlayer_pause(easyar_VideoPlayer * This)

C++17

void pause()

C++03(Deprecated)

void pause()

Java

public void pause()

Kotlin

fun pause(): Unit

Objective-C

- (void)pause

Swift

public func pause() -> Void

C#

public virtual void pause()

isRenderTextureAvailable

视频texture是否可以用于渲染。可以用于检查传入player的texture是否被碰过。

C

bool easyar_VideoPlayer_isRenderTextureAvailable(easyar_VideoPlayer * This)

C++17

bool isRenderTextureAvailable()

C++03(Deprecated)

bool isRenderTextureAvailable()

Java

public boolean isRenderTextureAvailable()

Kotlin

fun isRenderTextureAvailable(): Boolean

Objective-C

- (bool)isRenderTextureAvailable

Swift

public func isRenderTextureAvailable() -> Bool

C#

public virtual bool isRenderTextureAvailable()

updateFrame

更新texture数据。这个方法需要在isRenderTextureAvailable返回true的时候在渲染线程上调用。

C

void easyar_VideoPlayer_updateFrame(easyar_VideoPlayer * This)

C++17

void updateFrame()

C++03(Deprecated)

void updateFrame()

Java

public void updateFrame()

Kotlin

fun updateFrame(): Unit

Objective-C

- (void)updateFrame

Swift

public func updateFrame() -> Void

C#

public virtual void updateFrame()

duration

返回视频长度。在成功的open之后使用。

C

int easyar_VideoPlayer_duration(easyar_VideoPlayer * This)

C++17

int duration()

C++03(Deprecated)

int duration()

Java

public int duration()

Kotlin

fun duration(): Int

Objective-C

- (int)duration

Swift

public func duration() -> Int32

C#

public virtual int duration()

currentPosition

返回当前播放到的视频位置。在成功的open之后使用。

C

int easyar_VideoPlayer_currentPosition(easyar_VideoPlayer * This)

C++17

int currentPosition()

C++03(Deprecated)

int currentPosition()

Java

public int currentPosition()

Kotlin

fun currentPosition(): Int

Objective-C

- (int)currentPosition

Swift

public func currentPosition() -> Int32

C#

public virtual int currentPosition()

seek

将播放位置调整到 position 。在成功的open之后使用。

C

bool easyar_VideoPlayer_seek(easyar_VideoPlayer * This, int position)

C++17

bool seek(int position)

C++03(Deprecated)

bool seek(int position)

Java

public boolean seek(int position)

Kotlin

fun seek(position: Int): Boolean

Objective-C

- (bool)seek:(int)position

Swift

public func seek(_ position: Int32) -> Bool

C#

public virtual bool seek(int position)

size

返回视频长宽。在成功的open之后使用。

C

easyar_Vec2I easyar_VideoPlayer_size(easyar_VideoPlayer * This)

C++17

Vec2I size()

C++03(Deprecated)

Vec2I size()

Java

public @Nonnull Vec2I size()

Kotlin

fun size(): Vec2I

Objective-C

- (easyar_Vec2I *)size

Swift

public func size() -> Vec2I

C#

public virtual Vec2I size()

volume

返回视频音量。在成功的open之后使用。

C

float easyar_VideoPlayer_volume(easyar_VideoPlayer * This)

C++17

float volume()

C++03(Deprecated)

float volume()

Java

public float volume()

Kotlin

fun volume(): Float

Objective-C

- (float)volume

Swift

public func volume() -> Float

C#

public virtual float volume()

setVolume

设置视频音量。在成功的open之后使用。

C

bool easyar_VideoPlayer_setVolume(easyar_VideoPlayer * This, float volume)

C++17

bool setVolume(float volume)

C++03(Deprecated)

bool setVolume(float volume)

Java

public boolean setVolume(float volume)

Kotlin

fun setVolume(volume: Float): Boolean

Objective-C

- (bool)setVolume:(float)volume

Swift

public func setVolume(_ volume: Float) -> Bool

C#

public virtual bool setVolume(float volume)